<?php
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
$title="Quran By Subject| ايات القران مفهرسه حسب المواضيع";
?>
<?php include '../header.php'; ?>
<?php include '../settings.php'; ?>
<?php

echo "<a href='sura.php'>تعديل التصنيفات علي الايات</a><br>";
echo "<form name='myWebForm' action='".$adminlocation."postmaincats.php' method='post'>";

echo("تصنيف اساسي جديد: <input type='text' name='NewCategory'><br>");

echo("<br><input type='submit' value='اضف تصنيف جديد'></form><br><br>");

$con=mysqli_connect($host,$dbuserR,$dbpassR,$dbname);

//$con=mysqli_connect("localhost","quran","quran","Quran");
// Check connection
if (mysqli_connect_errno()) {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}




$result=mysqli_query($con,"select Category.CIndex as mememe, Category.CIndex,Category.Description,(select count(Category.CIndex) from Category where Category.Banned=0 and Category.ParentIndex=mememe ) as countrow from Category where Banned=0 and Category.ParentIndex=1 order by countrow DESC");





while($row = mysqli_fetch_array($result)) 
{
echo ("<a href='sura.php?Sura=".$row['CIndex']."'>");
echo $row['Description']." (".$row['countrow'].")<br>\n</a>";
}

echo "<br><br><br>";

$result=mysqli_query($con,"select Category.LongDescription,Category.ParentIndex,Category.CIndex,Category.Description,(select count(CategoryAya.CategoryIndex) from CategoryAya where CategoryAya.Banned=0 and Category.CIndex=CategoryAya.CategoryIndex ) as countrow from Category where Banned=0  order by ParentIndex,Description ");

$rownum1=mysqli_num_rows($result)+1;
//$rownum1=100;
echo "\n<script type='text/javascript'>\n";
echo "function showhide(what,obj) {\n";
echo "var aa='txt1_a_';\n";
echo "var bb='txt1_b_';\n";
echo "var cc='txt1_c_';\n";
echo "   if(what.checked) {\n";
echo "for (i = 1; i < ".$rownum1."; i++) {";
echo "var aai=aa+i.toString();";
echo "var bbi=bb+i.toString();";
echo "var cci=cc+i.toString();";

echo "       obj1 = document.getElementById(aai);\n";
echo "       obj1.style.display = 'inline';\n";
echo "       obj1 = document.getElementById(bbi);\n";
echo "       obj1.style.display = 'inline';\n";
echo "       obj1 = document.getElementById(cci);\n";
echo "       obj1.style.display = 'inline';\n";
echo "}\n";
echo "   } else {\n";
echo "for (i = 1; i < ".$rownum1."; i++) {";
echo "var aai=aa+i.toString();";
echo "var bbi=bb+i.toString();";
echo "var cci=cc+i.toString();";


echo "       obj1 = document.getElementById(aai);\n";
echo "       obj1.style.display = 'none';\n";
echo "       obj1 = document.getElementById(bbi);\n";
echo "       obj1.style.display = 'none';\n";
echo "       obj1 = document.getElementById(cci);\n";
echo "       obj1.style.display = 'none';\n";
echo "}\n";
echo "   }\n";
echo "}</script>\n";
echo ("<form>تعديل الوصف و الوصف الطويل للتصنيفات<input id='bob' type='checkbox' onclick=".'"'."showhide(this, 'txt1');".'"'."  /><p></p></form>");



echo "<form name='myWebForm2' action='".$adminlocation."postmaincats.php' method='post'>";
//echo ("<input type='checkbox' onclick=".'"'."showhide(this, 'txt1');".'"'." checked='checked' /><p><input type='input' id='txt1' /></p>");

echo ("تأكيد انك تريد مسح كل التصنيفات المختاره <input  type='checkbox' name='delete' value='delete'  /><p></p>");


$rownum=0;
while($row = mysqli_fetch_array($result)) 
{
$rownum=$rownum+1;
if($row['ParentIndex']<>"1")
{
echo "<select name='Cat[".$row['CIndex']."]'>";

//echo "<option value='116'>Import</option>";
$suras1 = mysqli_query($con,"select CIndex,Description From Category where  ParentIndex=1;");

If ($row['ParentIndex']=="") 
{
echo("<option value='' selected='selected'></option>");
}
else 
{
echo("<option value='' ></option>");
}


while($row1 = mysqli_fetch_array($suras1)) 
{
If ($row['ParentIndex']==$row1['CIndex'])
{

echo("<option value='".$row1['CIndex']."' selected='selected'>".$row1['Description']."</option>");
//$currenttitle=$row['name'];
}
else
{
echo("<option value='".$row1['CIndex']."' >".$row1['Description']."</option>");

}
}


echo "</select>";
}
echo ("<a href='sura.php?Sura=".$row['CIndex']."'>");
if($row['ParentIndex']<>"1")
{
echo $row['Description']." (".$row['countrow'].")</a><input style='display: none' id='txt1_a_".$rownum."' autocomplete='off' type='text' name='desc[".$row['CIndex']."]' value='".$row['Description']."'><input style='display: none' id='txt1_b_".$rownum."' autocomplete='off' type='text' name='ldesc[".$row['CIndex']."]' value='".$row['LongDescription']."'><input type='checkbox' name='CatDel[".$row['CIndex']."]' value='".$row['CIndex']."' id='txt1_c_".$rownum."' autocomplete='off' style='display: none' /><br>";
}
else
{
echo $row['Description']."</a><input style='display: none' id='txt1_a_".$rownum."' autocomplete='off' type='text' name='desc[".$row['CIndex']."]' value='".$row['Description']."'><input style='display: none' id='txt1_b_".$rownum."' autocomplete='off' type='txt' name='ldesc[".$row['CIndex']."]' value='".$row['LongDescription']."'><input type='checkbox' name='CatDel[".$row['CIndex']."]' value='".$row['CIndex']."' id='txt1_c_".$rownum."' autocomplete='off' style='display: none' /><br>";
}




























}



//echo "for (i = 0; i < ".$rownum."; i++) {";

//echo "}";

echo "</select><input type='submit' value='تغير التصنيفات' id='submit' /></form>";




